//
//  YSZHomeViewController.swift
//  swiftweibo6
//
//  Created by ysz on 15/11/22.
//  Copyright © 2015年 user. All rights reserved.
//

import UIKit

class YSZHomeViewController: YSZBaseTableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        if !userLogin
        {
            return
        }
        
        setupNav()
        
        YSZNetworkTools.shardInsatance.loadStatus { (result, error) -> () in
            print("取到数据\(result)")
        }
    }
    private func setupNav()
    {
        navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_friendsearch")
        navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: "navigationbar_pop")
        
        let screen_name = YSZUserAccount.loadUserAccount()?.screen_name ?? "ysz"
        let homeTitleButton = YSZHomeTitleButton(title: screen_name)
        
        navigationItem.titleView = homeTitleButton
        homeTitleButton.addTarget(self, action: "homeTitleButtoClick:", forControlEvents: .TouchUpInside)
    }

    func homeTitleButtoClick(button: UIButton)
    {
        button.selected = !button.selected
        
        UIView.animateWithDuration(0.25) { () -> Void in
            button.imageView?.transform = button.selected ? CGAffineTransformMakeRotation(CGFloat(M_PI-0.01)) : CGAffineTransformIdentity
        }
    }
    

}
